function fnScore(addTime, userId, friendId, token) { //初始化
	scoreDate(addTime, userId, friendId, token);
}
//接口
function scoreDate(addTime, userId, friendId, token) { //健康
	var url = "http://api.sungohealth.com/healthy/HealthScores";
	var data = {
		addTime: addTime,
		userId: userId,
		friendId: friendId,
		token: token,
	};
	$.ajax({
		type: "POST",
		url: url,
		data: data,
		dataType: "json",
		success: function(data, status, xhr) {
			console.log(data);
			if(data.status == '0' || data.msg == '成功') {
				$('.unEmpty').removeClass('dn');
				$('.empty').addClass('dn');
				fn_option_score(addTime, data); //数据渲染
			} else {
				$('.unEmpty').addClass('dn');
				$('.empty').removeClass('dn');
			}
		},
		error: function(result) {
			console.log(result);
		}
	});
}

//
//var dataTemp = {
//      "status": 0,
//      "data": [
//          {"home_date": "2018-03-10", "score_all": "9"},
//          {"home_date": "2018-03-23", "score_all": "4"}
//      ]};
//fn_option('2018-04-03',dataTemp);

function fn_option_score(time, data) { //数据渲染
	//  $('.unEmpty').removeClass('dn');$('.empty').addClass('dn');

	//数据处理
	var last16 = dayList(time).last16; //日期
	var dataTemp = dayList(time).ecShow; //echart日期
	var uesTemp = dayList(time).ecUse; //echart日期下标

	var data_arr = data.data;
	var option2_date = [];

	$.each(last16, function(key, val) { //日期数据比对，生成echart需要数据
		$.each(data_arr, function(k, v) {
			if(val == v.home_date) {
				option2_date[key] = v.score_all;
			}
		});
	});

	//健康
	var option = {
		grid: {
			y: 20,
			x2: 14,
			y2: 30,
			x: 40
		}, //边距
		tooltip: { //提示框
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				},
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 65, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容
				var timeTemp = dataTemp[params[0].dataIndex].split('/');
				var timeShow = timeTemp[0] + '月' + timeTemp[1] + '日';
				var res = '<div class="tooltip"><p>' + timeShow + '</p>';
				for(var i = 0; i < params.length; i++) {
					if(i == 0) {
						if(params[i].data) {
							res += '<p>分值：' + params[i].data + '</p>'
						} else {
							res += '<p>分值：---</p>'
						}
					}
				}
				res += '</div>';
				return res;
			},
		},
		xAxis: { //x轴
			type: 'category',
			boundaryGap: false,
			data: uesTemp, //日期下标数据
			axisLabel: {
				interval: 0,
				textStyle: {
					color: '#999'
				}
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		yAxis: { //y轴
			scale: true,
			max: 100,
			min: 0,
			splitNumber: 5,
			type: 'value',
			axisLabel: {
				show: true,
				textStyle: {
					color: '#999'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		series: [{
			type: 'line',
			smooth: true,
			data: option2_date, //健康数据
			itemStyle: {
				normal: {
					color: '#86d9e0',
					lineStyle: {
						color: '#86d9e0'
					}
				}
			},
		}],
	};

	echarts.init(document.getElementById("score")).setOption(option, true);

}